package com.arraylist;

import java.util.ArrayList;
import java.util.Iterator;

public class StudentTest2 {
    public static void main(String[] args) {
        ArrayList<Student1> arrayList = new ArrayList();
        arrayList.add(new Student1("zhangsan",20));
        arrayList.add(new Student1("zhaoliu",18));
        arrayList.add(new Student1("xiaohog",27));
        arrayList.add(new Student1("lisi",13));
        arrayList.add(new Student1("wangwu",25  ));
        Integer age0 = arrayList.get(0).getAge();
        Integer k = 0;
        for (int i = 1; i < arrayList.size(); i++) {
            Integer age = arrayList.get(i).getAge();
            if (age > age0) {
                age0 = age;
                k = i;
            }
        }
        System.out.println(arrayList.get(k));




    }
}
